<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-on指令</title>
    <script src="vue.js"></script>
    <style>
        .redcls{
            width: 100px;
            height: 80px;
            background-color: red;
        }
        .greencls{
            width: 100px;
            height: 80px;
            background-color:green;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="redcls" @click="changeBgColor" v-bind:class="classA"></div>
        <button @click="changePic">变图</button><br>
        <img :src="picPath">
    </div>
</body>
</html>
<script>
    var vm=new Vue({
        el:'#app',
        data:{
            classA:'',
            picPath:'images/userface2.jpg'
        },
        methods: {
            changeBgColor:function(){
                this.classA='greencls'
            },
            changePic:function(){
                this.picPath='images/userface4.jpg';
            }
        }
    });
</script>